---
category: DOM
created: '2020-04-19'
title: Strip HTML from a given text
updated: '2021-10-13'
---

**JavaScript version**

```js stripHtml.js
const stripHtml = (html) => new DOMParser().parseFromString(html, 'text/html').body.textContent || '';
```

**TypeScript version**

```ts stripHtml.ts
const stripHtml = (html: string): string => new DOMParser().parseFromString(html, 'text/html').body.textContent || '';
```
